package info.manxi;

import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.Props;

/**
 * <pre>
 * <b>Description</b>
 * </pre>
 * <pre>
 * 创建时间 2019-11-25 15:37
 * 所属工程： akka-actor-101  </pre>
 *
 * @author sheldon yhid: 80752866
 */
public class Girl extends AbstractActor {
    static Props props() {
        return Props.create(Girl.class, Girl::new);
    }
    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(Love.class, love -> {
                    System.out.println("我收到了" + getSender() + "的消息：" + love.getMsg() + "，还有" + love.getMoney() + "元钱！");
                    getSender().tell("will you baoyang me?", getSelf());
                })
                .match(String.class, msg -> {
                    System.out.println("我收到了" + getSender() + "的消息： " + msg);
                    if (msg.equals("Yes I do")) {
                        System.out.println("哇撒！买买买 我是爱买的女孩~");
                    }
//                    ActorSelection selection = getContext().actorSelection("/user/gossipgirl");
//                    selection.tell("我在购物..", getSelf());
                    getSelf().tell("我在购物...", ActorRef.noSender());
                    Thread.sleep(1000);
                })
                .build();
    }
}
